package tij4.concurrent.exercise.ex05;

import java.util.concurrent.Callable;

public class Practice01 implements Callable<Integer> {

    private int n;

    public Practice01(int n){
        this.n = n;
    }

    public int fib(int i){
        if(i < 2)
            return 1;
        return fib(i-1) + fib(i-2);
    }

    @Override
    public Integer call() throws Exception {

        int sum = 0;
        for (int i = 0; i < n; i++) {
            System.out.println(Thread.currentThread().getName() + ": sum-"+sum + "  fib("+i+")-"+fib(i));
            sum += fib(i);
        }

        return sum;
    }
}
